package com.wfm.service.deploy;

import com.alibaba.excel.EasyExcel;
import java.io.File;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("easyExcelService1")
@Slf4j
public class EasyExcelService1 {
    @Autowired
    DemoDAO demoDAO;
    public void simpleRead(){
//        String fileName = TestFileUtil.getPath() + "demo" + File.separator + "a.xlsx";
        String fileName = "C:\\Users\\fuminwu\\Downloads\\ct uat发布 (1).xlsx";
        // 这里 需要指定读用哪个class去读，然后读取第一个sheet 文件流会自动关闭
        // 有个很重要的点 DemoDataListener 不能被spring管理，要每次读取excel都要new,然后里面用到spring可以构造方法传进去
        EasyExcel.read(fileName,
                DemoData.class,
                new DemoDataListener(demoDAO))
                .headRowNumber(1235)
//                .registerConverter(new CustomStringStringConverter())
                .sheet()
                .doRead();
    }

}
